package com.gaofeng.day09;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Demo03 {
    // list 迭代器

    public static void main(String[] args) {
        Collection<String> coll = new ArrayList<>();
        coll.add("aaa");
        coll.add("bbb");
        coll.add("ccc");
        System.out.println(coll);

        Iterator<String> it = coll.iterator();
//        while (it.hasNext()) {
//            String next = it.next();
//            System.out.println(next);
//        }
//        System.out.println(it.next());
        Iterator<String> coll2 = coll.iterator();
        while (coll2.hasNext()) {
            String next = coll2.next();
            if ("aaa".equals(next)) {
                coll2.remove();
            }
            System.out.println(next);
        }
        System.out.println(coll);
    }


}
